package com.cskaoyan.controller.admin.marketmanagement;

import com.cskaoyan.bean.MarketKeyword;
import com.cskaoyan.bean.bo.admin.keyword.KeywordListBo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.admin.keyword.KeywordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Aaliyah
 * @date 2022/9/8 11:14
 * @description: 处理关键词模块的请求
 */
@RequestMapping("admin/keyword")
@RestController
public class KeywordController {

    @Autowired
    KeywordService keywordService;

    /**
     * @description: /admin/keyword/list 请求的处理
     * @date: 2022/9/8 11:16
     * @param: [keywordListBo] 封装了搜索条件和分页信息
     */
    @RequestMapping("list")
    public BaseRespVo<CommonData<MarketKeyword>> keywordList(KeywordListBo keywordListBo) {
        return BaseRespVo.ok(keywordService.keywordList(keywordListBo));
    }

    /**
     * @description: /admin/keyword/create 请求的处理
     * @date: 2022/9/8 12:13
     * @param: [marketKeyword] 封装了新增的关键词信息
     */
    @RequestMapping("create")
    public BaseRespVo<MarketKeyword> keywordCreate(@RequestBody MarketKeyword marketKeyword) {
        return BaseRespVo.ok(keywordService.keywordCreate(marketKeyword));
    }

    /**
     * @description: /admin/keyword/update 请求的处理
     * @date: 2022/9/8 14:46
     * @param: [marketKeyword] 封装了更新后的关键词信息，含id
     */
    @RequestMapping("update")
    public BaseRespVo<MarketKeyword> keywordUpdate(@RequestBody MarketKeyword marketKeyword) {
        return BaseRespVo.ok(keywordService.keywordUpdate(marketKeyword));
    }

    /**
     * @description: /admin/keyword/delete 请求的处理
     * @date: 2022/9/8 14:56
     * @param: [marketKeyword] 封装了需要删除的关键词的信息，含id
     */
    @RequestMapping("delete")
    public BaseRespVo<MarketKeyword> keywordDelete(@RequestBody MarketKeyword marketKeyword) {
        keywordService.keywordDelete(marketKeyword);
        return BaseRespVo.ok(null);
    }
}
